The networkDifferences-aspect in a nutshell: This vignette explains the NetworkDifferences aspect in detail but this section summarizes the main ideas:
The NetworkDifferences aspect tracks the differences of two networks represented as RCX-objects. The compareNetworks-function returns an RCX-object whereby the nodes-, nodeAttributes-, edges-, and edgeAttributes-aspects are a combination of the two given RCX-objects left and right. This RCX-object has the NetworkDifferences aspect, too, which is a list containing five dataframes to monitor the differences regarding the nodes, nodeAttributes, edges, edgeAttributes, and networkAttributes.
The RCX-object including the NetworkDifferences aspect can be converted to the json-based data structure CX and back by using the toCX- and processCX-functions provided by the RCX package.
The NetworkDifferences aspect can be converted to RCX-objects that visualize the differences of the two given networks with focus on their topology. The user can select if the RCX-object should be node-centered, edge-centered, or a combination and if the attributes and their values should be included. The conversion to an RCX object allows to store, share, and visualize the NetworkDifferences aspect.
The NetworkDifferences aspect allows the tracking and visualization of the differences of two RCX-objects. The first part of this vignette explains in detail how this aspect works and at the end we take a closer look at how this functionality can be used for a real-life example. Many biological entities like proteins and genes are represented as biological networks with nodes and edges and comparing these networks can help to answer questions in medical research e. g. the real-life example illustrates how the NetworkDifferences aspect can be used to visualize the differences regarding genes, gene expression and other aspects of two breast cancer patients.
The NetworkDifferences aspect website is available at https://github.com/frankkramer-lab/RCX-NetworkDifferences
This package is an extension of the RCX package by Florian Auer (Bioconductor: https://bioconductor.org/packages/release/bioc/html/RCX.html, Github: https://github.com/frankkramer-lab/RCX). The json-based data structure CX is often used to store biological networks and the RCX package adapts the CX format to standard R data formats to create, modify, load, export, and visualize networks.
Two RCX-objects left and right are created and function as examples later.
left <- createRCX(
nodes = createNodes(
id = 0:2, name = c("A", "B", "C"),
represents = c("r1", "r2", "r3")
),
edges = createEdges(
source = c(0, 1, 2),
target = c(1, 2, 0),
interaction = c("E1", "E2", "E3")
),
nodeAttributes = createNodeAttributes(
propertyOf = c(0, 1),
name = rep("type", 2),
value = list("w", c("x", "y"))
),
edgeAttributes = createEdgeAttributes(
propertyOf = c(0, 1),
name = rep("type", 2),
value = c("k", "l")
),
networkAttributes = createNetworkAttributes(
name = c("name", "author"),
value = c("left network", "Donald Duck")
)
)
right <- createRCX(
nodes = createNodes(
name = c("A", "B", "X"),
represents = c("r1", "r4", "r5")
),
edges = createEdges(
source = c(0, 1, 2),
target = c(1, 2, 0),
interaction = c("E1", "E2", "E3")
),
nodeAttributes = createNodeAttributes(
propertyOf = c(0, 1),
name = c("type", "type"),
value = list("z", c("x", "y"))
),
edgeAttributes = createEdgeAttributes(
propertyOf = c(0, 1),
name = rep("type", 2),
value = list("n", c("l", "m"))
),
networkAttributes = createNetworkAttributes(
name = c("name", "description"),
value = c("right network", "sample network")
)
)
The compareNetworks-function is provided to track the differences regarding the nodes, nodeAttributes, edges, edgeAttributes, and networkAttributes and has three parameters: the two RCX-objects left and right, and the boolean matchByName. The names left and right are based on the join-operation. If matchByName is TRUE, two nodes are equal when their names are equal; if matchByName is FALSE, two nodes are equal when their represents are equal.
To illustrate the difference between matchByName set to TRUE respectively FALSE, we define two RCX-objects called rcxMatchByNameTRUE and rcxMatchByNameFALSE.
rcxMatchByNameTRUE <- compareNetworks(left, right, matchByName = TRUE)
rcxMatchByNameFALSE <- compareNetworks(left, right, matchByName = FALSE)
The function returns an RCX-object whereby the nodes, nodeAttributes, edges, and edgeAttributes of the right network are appended to the corresponding aspects of the left network. The networkAttributes are ignored as it is not possible to append the networkAttributes of the right network to the networkAttributes of the left network if two networkAttributes have the same name. An additional aspect called the NetworkDifferences aspect is added to the RCX-object. It is a list with the matchByName-boolean and five dataframes to track the differences of nodes, nodeAttributes, edges, edgeAttributes, and networkAttributes of the two RCX-objects.
The structure of the returned RCX object is:
|---nodes: left nodes, right nodes
|---nodeAttributes: left nodeAttributes, right nodeAttributes
|---edges: left edges, right edges
|---edgeAttributes: left edgeAttributes, right edgeAttributes
|---networkDifferences
| |---matchByName: logical, if TRUE two nodes are equal when their names are equal,
if FALSE two nodes are equal when their represents are equal
| |---nodes: differences of the nodes (columns depend on matchByName: id, name/nameLeft, representLeft/nameRight, representRight/represent, oldIdLeft, oldIdRight, belongsToLeft, belongsToRight)
| |---nodeAttributes: differences of the nodeAttributes (columns: propertyOf, name, belongsToLeft, belongsToRight, dataTypeLeft, dataTypeRight, isListLeft, isListRight, valueLeft, valueRight)
| |---edges: differences of the edges (columns: id, source, target, interaction, oldIdLeft, oldIdRight, belongsToLeft, belongsToRight)
| |---edgeAttributes: differences of the edgeAttributes (columns: propertyOf, name, belongsToLeft, belongsToRight, dataTypeLeft, dataTypeRight, isListLeft, isListRight, valueLeft, valueRight)
| |---networkAttributes: differences of the networkAttributes (columns: name, belongsToLeft, belongsToRight, dataTypeLeft, dataTypeRight, isListLeft, isListRight, valueLeft, valueRight)
The structure of the NetworkDifferences aspect is visible after a conversion to JSON.
toCX(rcxMatchByNameTRUE, pretty = TRUE)
## [
## {
## "numberVerification": [
## {
## "longNumber": 2147483647
## }
## ]
## },
## {
## "metaData": [
## {
## "name": "nodes",
## "version": "1.0",
## "idCounter": 5,
## "elementCount": 6,
## "consistencyGroup": 1
## },
## {
## "name": "edges",
## "version": "1.0",
## "idCounter": 5,
## "elementCount": 6,
## "consistencyGroup": 1
## },
## {
## "name": "nodeAttributes",
## "version": "1.0",
## "elementCount": 4,
## "consistencyGroup": 1
## },
## {
## "name": "edgeAttributes",
## "version": "1.0",
## "elementCount": 4,
## "consistencyGroup": 1
## },
## {
## "name": "networkDifferences",
## "version": "1.0",
## "elementCount": 1,
## "consistencyGroup": 1
## }
## ]
## },
## {
## "nodes": [
## {
## "@id": 0,
## "n": "A",
## "r": "r1",
## "oldId": 0
## },
## {
## "@id": 1,
## "n": "B",
## "r": "r2",
## "oldId": 1
## },
## {
## "@id": 2,
## "n": "C",
## "r": "r3",
## "oldId": 2
## },
## {
## "@id": 3,
## "n": "A",
## "r": "r1",
## "oldId": 0
## },
## {
## "@id": 4,
## "n": "B",
## "r": "r4",
## "oldId": 1
## },
## {
## "@id": 5,
## "n": "X",
## "r": "r5",
## "oldId": 2
## }
## ]
## },
## {
## "edges": [
## {
## "@id": 0,
## "s": 0,
## "t": 1,
## "i": "E1",
## "oldId": 0
## },
## {
## "@id": 1,
## "s": 1,
## "t": 2,
## "i": "E2",
## "oldId": 1
## },
## {
## "@id": 2,
## "s": 2,
## "t": 0,
## "i": "E3",
## "oldId": 2
## },
## {
## "@id": 3,
## "s": 3,
## "t": 4,
## "i": "E1",
## "oldId": 0
## },
## {
## "@id": 4,
## "s": 4,
## "t": 5,
## "i": "E2",
## "oldId": 1
## },
## {
## "@id": 5,
## "s": 5,
## "t": 3,
## "i": "E3",
## "oldId": 2
## }
## ]
## },
## {
## "nodeAttributes": [
## {
## "po": 0,
## "n": "type",
## "v": "w",
## "d": "string"
## },
## {
## "po": 1,
## "n": "type",
## "v": [
## "x",
## "y"
## ],
## "d": "list_of_string"
## },
## {
## "po": 3,
## "n": "type",
## "v": "z",
## "d": "string"
## },
## {
## "po": 4,
## "n": "type",
## "v": [
## "x",
## "y"
## ],
## "d": "list_of_string"
## }
## ]
## },
## {
## "edgeAttributes": [
## {
## "po": 0,
## "n": "type",
## "v": "k",
## "d": "string"
## },
## {
## "po": 1,
## "n": "type",
## "v": "l",
## "d": "string"
## },
## {
## "po": 3,
## "n": "type",
## "v": "n",
## "d": "string"
## },
## {
## "po": 4,
## "n": "type",
## "v": [
## "l",
## "m"
## ],
## "d": "list_of_string"
## }
## ]
## },
## {
## "networkDifferences": [
## {
## "matchByName": "true"
## },
## {
## "nodes": [
## {
## "@id": "0",
## "n": "A",
## "rl": "r1",
## "rr": "r1",
## "oil": "0",
## "oir": "0",
## "btl": "TRUE",
## "btr": "TRUE"
## },
## {
## "@id": "1",
## "n": "B",
## "rl": "r2",
## "rr": "r4",
## "oil": "1",
## "oir": "1",
## "btl": "TRUE",
## "btr": "TRUE"
## },
## {
## "@id": "2",
## "n": "C",
## "rl": "r3",
## "oil": "2",
## "btl": "TRUE",
## "btr": "FALSE"
## },
## {
## "@id": "3",
## "n": "X",
## "rr": "r5",
## "oir": "2",
## "btl": "FALSE",
## "btr": "TRUE"
## }
## ]
## },
## {
## "nodeAttributes": [
## {
## "po": "0",
## "n": "type",
## "btl": "TRUE",
## "btr": "TRUE",
## "dtl": "string",
## "dtr": "string",
## "ill": "FALSE",
## "ilr": "FALSE",
## "vl": "w",
## "vr": "z"
## },
## {
## "po": "1",
## "n": "type",
## "btl": "TRUE",
## "btr": "TRUE",
## "dtl": "string",
## "dtr": "string",
## "ill": "TRUE",
## "ilr": "TRUE",
## "vl": "c(\"x\", \"y\")",
## "vr": "c(\"x\", \"y\")"
## }
## ]
## },
## {
## "edges": [
## {
## "@id": "0",
## "s": "0",
## "t": "1",
## "i": "E1",
## "oil": "0",
## "oir": "0",
## "btl": "TRUE",
## "btr": "TRUE"
## },
## {
## "@id": "1",
## "s": "1",
## "t": "2",
## "i": "E2",
## "oil": "1",
## "btl": "TRUE",
## "btr": "FALSE"
## },
## {
## "@id": "2",
## "s": "2",
## "t": "0",
## "i": "E3",
## "oil": "2",
## "btl": "TRUE",
## "btr": "FALSE"
## },
## {
## "@id": "3",
## "s": "1",
## "t": "3",
## "i": "E2",
## "oir": "1",
## "btl": "FALSE",
## "btr": "TRUE"
## },
## {
## "@id": "4",
## "s": "3",
## "t": "0",
## "i": "E3",
## "oir": "2",
## "btl": "FALSE",
## "btr": "TRUE"
## }
## ]
## },
## {
## "edgeAttributes": [
## {
## "po": "0",
## "n": "type",
## "btl": "TRUE",
## "btr": "TRUE",
## "dtl": "string",
## "dtr": "string",
## "ill": "FALSE",
## "ilr": "FALSE",
## "vl": "k",
## "vr": "n"
## },
## {
## "po": "1",
## "n": "type",
## "btl": "TRUE",
## "btr": "FALSE",
## "dtl": "string",
## "ill": "FALSE",
## "vl": "l"
## },
## {
## "po": "3",
## "n": "type",
## "btl": "FALSE",
## "btr": "TRUE",
## "dtr": "string",
## "ilr": "TRUE",
## "vr": "c(\"l\", \"m\")"
## }
## ]
## },
## {
## "networkAttributes": [
## {
## "n": "name",
## "btl": "TRUE",
## "btr": "TRUE",
## "dtl": "string",
## "dtr": "string",
## "ill": "FALSE",
## "ilr": "FALSE",
## "vl": "left network",
## "vr": "right network"
## },
## {
## "n": "author",
## "btl": "TRUE",
## "btr": "FALSE",
## "dtl": "string",
## "ill": "FALSE",
## "vl": "Donald Duck"
## },
## {
## "n": "description",
## "btl": "FALSE",
## "btr": "TRUE",
## "dtr": "string",
## "ilr": "TRUE",
## "vr": "sample network"
## }
## ]
## }
## ]
## },
## {
## "status": [
## {
## "error": "",
## "success": true
## }
## ]
## }
## ]
##
The combined network adds the aspects of the right network to the left network. For the nodes it is:
rcxMatchByNameTRUE$nodes
## Nodes:
## id name represents oldId
## 1 0 A r1 0
## 2 1 B r2 1
## 3 2 C r3 2
## 4 3 A r1 0
## 5 4 B r4 1
## 6 5 X r5 2
The nodeAttributes have updated values for propertyOf for nodeAttributes originating from the right network.
rcxMatchByNameTRUE$nodeAttributes
## Node attributes:
## propertyOf name value dataType isList
## 1 0 type w string FALSE
## 2 1 type x, y string TRUE
## 3 3 type z string FALSE
## 4 4 type x, y string TRUE
The dataframe for the edges contains updated values for source and target for edges originating from the right network.
rcxMatchByNameTRUE$edges
## Edges:
## id source target interaction oldId
## 1 0 0 1 E1 0
## 2 1 1 2 E2 1
## 3 2 2 0 E3 2
## 4 3 3 4 E1 0
## 5 4 4 5 E2 1
## 6 5 5 3 E3 2
The last aspect are the edgeAttributes, again with updated values for propertyOf for the edgeAttributes originating from the right network.
rcxMatchByNameTRUE$edgeAttributes
## Edge attributes:
## propertyOf name value dataType isList
## 1 0 type k string FALSE
## 2 1 type l string FALSE
## 3 3 type n string FALSE
## 4 4 type l, m string TRUE
The NetworkDifferences-aspect contains the information regarding the differences of nodes, nodeAttributes, edges, edgeAttributes, and networkÀttributes.
The nodes-dataframe
The nodes-dataframe tracks the differences of the nodes in eight columns. The names of the columns depend on the matchByName-boolean. If matchByName is TRUE the names of the columns are: id, name, representLeft, representRight, oldIdLeft, oldIdRight, belongsToLeft, and belongsToRight. If matchByName is FALSE the names of the columns are: id, name, representLeft, representRight, oldIdLeft, oldIdRight, belongsToLeft, and belongsToRight.
Example: The left network has three nodes called A, B, and C with the represents r1, r2, and r3.
left$nodes
## Nodes:
## id name represents
## 1 0 A r1
## 2 1 B r2
## 3 2 C r3
The right network has three nodes called A, B, and X with the represents r1, r4, and r5.
right$nodes
## Nodes:
## id name represents
## 1 0 A r1
## 2 1 B r4
## 3 2 X r5
If matchByName is TRUE, the created nodes-dataframe of the NetworkDifferences aspect is:
rcxMatchByNameTRUE$networkDifferences$nodes
## id name representLeft representRight oldIdLeft oldIdRight belongsToLeft
## 1 0 A r1 r1 0 0 TRUE
## 2 1 B r2 r4 1 1 TRUE
## 3 2 C r3 <NA> 2 <NA> TRUE
## 4 3 X <NA> r5 <NA> 2 FALSE
## belongsToRight
## 1 TRUE
## 2 TRUE
## 3 FALSE
## 4 TRUE
If matchByName is FALSE, the created nodes-dataframe is:
rcxMatchByNameFALSE$networkDifferences$nodes
## id nameLeft nameRight represent oldIdLeft oldIdRight belongsToLeft
## 1 0 A A r1 0 0 TRUE
## 2 1 B <NA> r2 1 <NA> TRUE
## 3 2 C <NA> r3 2 <NA> TRUE
## 4 3 <NA> B r4 <NA> 1 FALSE
## 5 4 <NA> X r5 <NA> 2 FALSE
## belongsToRight
## 1 TRUE
## 2 FALSE
## 3 FALSE
## 4 TRUE
## 5 TRUE
The nodeAttributes-dataframe
The nodeAttributes-dataframe tracks the differences of the nodeAttributes in ten columns (propertyOf, name, belongsToLeft, belongsToRight, dataTypeLeft, dataTypeRight, isListLeft, isListRight, valueLeft, and valueRight). Two nodeAttributes are equal if their names are equal and if they belong to the same node (defined through propertyOf).
Example: The nodes from section 1.2.1 have nodeAttributes: In both RCX-objects, the nodes with the id 0 and 1 have the attribute ‘type’.
left$nodeAttributes
## Node attributes:
## propertyOf name value dataType isList
## 1 0 type w string FALSE
## 2 1 type x, y string TRUE
right$nodeAttributes
## Node attributes:
## propertyOf name value dataType isList
## 1 0 type z string FALSE
## 2 1 type x, y string TRUE
If matchByName is TRUE, the nodeAttributes-dataframe of the NetworkDifferences aspect is:
rcxMatchByNameTRUE$networkDifferences$nodeAttributes
## propertyOf name belongsToLeft belongsToRight dataTypeLeft dataTypeRight
## 1 0 type TRUE TRUE string string
## 2 1 type TRUE TRUE string string
## isListLeft isListRight valueLeft valueRight
## 1 FALSE FALSE w z
## 2 TRUE TRUE c("x", "y") c("x", "y")
If matchByName is FALSE, the nodeAttributes-dataframe is:
rcxMatchByNameFALSE$networkDifferences$nodeAttributes
## propertyOf name belongsToLeft belongsToRight dataTypeLeft dataTypeRight
## 1 0 type TRUE TRUE string string
## 2 1 type TRUE FALSE string <NA>
## 3 3 type FALSE TRUE <NA> string
## isListLeft isListRight valueLeft valueRight
## 1 FALSE FALSE w z
## 2 TRUE <NA> c("x", "y") <NA>
## 3 <NA> TRUE <NA> c("x", "y")
The edge-dataframe
The edges-dataframe tracks the differences of the edges in eight columns (id, source, target, interaction, oldIdLeft, oldIdRight, belongsToLeft, and belongsToRight). Two edges are equal if their source and target are equal (the edges are undirected so source and target can be switched) and if the interaction is equal or NA in both cases.
Example: Both RCX-objects from section 1.2.1 and 1.2.2 have three edges which have the interaction ‘E1’, ‘E2’, and ‘E3’.
left$edges
## Edges:
## id source target interaction
## 1 0 0 1 E1
## 2 1 1 2 E2
## 3 2 2 0 E3
right$edges
## Edges:
## id source target interaction
## 1 0 0 1 E1
## 2 1 1 2 E2
## 3 2 2 0 E3
If matchByName is set to TRUE, the edges-dataframe of the NetworkDifferences aspect is:
rcxMatchByNameTRUE$networkDifferences$edges
## id source target interaction oldIdLeft oldIdRight belongsToLeft
## 1 0 0 1 E1 0 0 TRUE
## 2 1 1 2 E2 1 <NA> TRUE
## 3 2 2 0 E3 2 <NA> TRUE
## 4 3 1 3 E2 <NA> 1 FALSE
## 5 4 3 0 E3 <NA> 2 FALSE
## belongsToRight
## 1 TRUE
## 2 FALSE
## 3 FALSE
## 4 TRUE
## 5 TRUE
If matchByName is set to FALSE, the edges-dataframe is:
rcxMatchByNameFALSE$networkDifferences$edges
## id source target interaction oldIdLeft oldIdRight belongsToLeft
## 1 0 0 1 E1 0 <NA> TRUE
## 2 1 1 2 E2 1 <NA> TRUE
## 3 2 2 0 E3 2 <NA> TRUE
## 4 3 0 3 E1 <NA> 0 FALSE
## 5 4 3 4 E2 <NA> 1 FALSE
## 6 5 4 0 E3 <NA> 2 FALSE
## belongsToRight
## 1 FALSE
## 2 FALSE
## 3 FALSE
## 4 TRUE
## 5 TRUE
## 6 TRUE
The edgeAttributes-dataframe
The edgeAttributes-dataframe tracks the differences of the edgeAttributes in ten columns (propertyOf, name, belongsToLeft, belongsToRight, dataTypeLeft, dataTypeRight, isListLeft, isListRight, valueLeft, and valueRight). Two edgeAttributes are equal if their names are equal and if they belong to the same edge (defined through propertyOf).
Example: The edges from section 1.2.3 have edgeAttributes: In both RCX-objects, the edges with the id 0 and 1 have the attribute ‘type’.
left$edgeAttributes
## Edge attributes:
## propertyOf name value dataType isList
## 1 0 type k string FALSE
## 2 1 type l string FALSE
right$edgeAttributes
## Edge attributes:
## propertyOf name value dataType isList
## 1 0 type n string FALSE
## 2 1 type l, m string TRUE
If matchByName is TRUE, the edgeAttributes-dataframe of the NetworkDifferences aspect is:
rcxMatchByNameTRUE$networkDifferences$edgeAttributes
## propertyOf name belongsToLeft belongsToRight dataTypeLeft dataTypeRight
## 1 0 type TRUE TRUE string string
## 2 1 type TRUE FALSE string <NA>
## 3 3 type FALSE TRUE <NA> string
## isListLeft isListRight valueLeft valueRight
## 1 FALSE FALSE k n
## 2 FALSE <NA> l <NA>
## 3 <NA> TRUE <NA> c("l", "m")
If matchByName is FALSE, the edgeAttributes-dataframe is:
rcxMatchByNameFALSE$networkDifferences$edgeAttributes
## propertyOf name belongsToLeft belongsToRight dataTypeLeft dataTypeRight
## 1 0 type TRUE FALSE string <NA>
## 2 1 type TRUE FALSE string <NA>
## 3 3 type FALSE TRUE <NA> string
## 4 4 type FALSE TRUE <NA> string
## isListLeft isListRight valueLeft valueRight
## 1 FALSE <NA> k <NA>
## 2 FALSE <NA> l <NA>
## 3 <NA> FALSE <NA> n
## 4 <NA> TRUE <NA> c("l", "m")
The networkAttributes-dataframe
The networkAttributes-dataframes tracks the differences of the networkAttributes in nine columns (name, belongsToLeft, belongsToRight, dataTypeLeft, dataTypeRight, isListLeft, isListRight, valueLeft, and valueRight). Two networkAttributes are equal if their names are equal.
Example: The left and right RCX-objects have networkAttributes: the left RCX-object has the name ‘left network’ and the author ‘Donald Duck’.
left$networkAttributes
## Network attributes:
## name value dataType isList
## 1 name left network string FALSE
## 2 author Donald Duck string FALSE
The right RCX-object has the name ‘right network’ and the description ‘sample network’.
right$networkAttributes
## Network attributes:
## name value dataType isList
## 1 name right network string FALSE
## 2 description sample network string FALSE
The networkAttributes-dataframe of the NetworkDifferences aspect is:
rcxMatchByNameTRUE$networkDifferences$networkAttributes
## name belongsToLeft belongsToRight dataTypeLeft dataTypeRight
## 1 name TRUE TRUE string string
## 2 author TRUE FALSE string <NA>
## 3 description FALSE TRUE <NA> string
## isListLeft isListRight valueLeft valueRight
## 1 FALSE FALSE left network right network
## 2 FALSE <NA> Donald Duck <NA>
## 3 <NA> TRUE <NA> sample network
The RCX-objects including the NetworkDifferences aspect can be converted into the json-based CX format and back in order to share the object. To convert the RCX-object into CX, the toCX function from the RCX package is used.
json <- toCX(rcxMatchByNameTRUE, verbose = TRUE, pretty = TRUE)
## Processing standard aspects: RCX$metaData:
## Convert meta-data to JSON...done!
## Processing standard aspects: RCX$nodes:
## Convert nodes to JSON...done!
## Processing standard aspects: RCX$edges:
## Convert edges to JSON...done!
## Processing standard aspects: RCX$nodeAttributes:
## Convert node attributes to JSON...done!
## Processing standard aspects: RCX$edgeAttributes:
## Convert edge attributes to JSON...done!
## Processing non-standard aspects: RCX$networkDifferences:
## Convert NetworkDifferences to JSON...done!
## Done with RCX!
json
## [
## {
## "numberVerification": [
## {
## "longNumber": 2147483647
## }
## ]
## },
## {
## "metaData": [
## {
## "name": "nodes",
## "version": "1.0",
## "idCounter": 5,
## "elementCount": 6,
## "consistencyGroup": 1
## },
## {
## "name": "edges",
## "version": "1.0",
## "idCounter": 5,
## "elementCount": 6,
## "consistencyGroup": 1
## },
## {
## "name": "nodeAttributes",
## "version": "1.0",
## "elementCount": 4,
## "consistencyGroup": 1
## },
## {
## "name": "edgeAttributes",
## "version": "1.0",
## "elementCount": 4,
## "consistencyGroup": 1
## },
## {
## "name": "networkDifferences",
## "version": "1.0",
## "elementCount": 1,
## "consistencyGroup": 1
## }
## ]
## },
## {
## "nodes": [
## {
## "@id": 0,
## "n": "A",
## "r": "r1",
## "oldId": 0
## },
## {
## "@id": 1,
## "n": "B",
## "r": "r2",
## "oldId": 1
## },
## {
## "@id": 2,
## "n": "C",
## "r": "r3",
## "oldId": 2
## },
## {
## "@id": 3,
## "n": "A",
## "r": "r1",
## "oldId": 0
## },
## {
## "@id": 4,
## "n": "B",
## "r": "r4",
## "oldId": 1
## },
## {
## "@id": 5,
## "n": "X",
## "r": "r5",
## "oldId": 2
## }
## ]
## },
## {
## "edges": [
## {
## "@id": 0,
## "s": 0,
## "t": 1,
## "i": "E1",
## "oldId": 0
## },
## {
## "@id": 1,
## "s": 1,
## "t": 2,
## "i": "E2",
## "oldId": 1
## },
## {
## "@id": 2,
## "s": 2,
## "t": 0,
## "i": "E3",
## "oldId": 2
## },
## {
## "@id": 3,
## "s": 3,
## "t": 4,
## "i": "E1",
## "oldId": 0
## },
## {
## "@id": 4,
## "s": 4,
## "t": 5,
## "i": "E2",
## "oldId": 1
## },
## {
## "@id": 5,
## "s": 5,
## "t": 3,
## "i": "E3",
## "oldId": 2
## }
## ]
## },
## {
## "nodeAttributes": [
## {
## "po": 0,
## "n": "type",
## "v": "w",
## "d": "string"
## },
## {
## "po": 1,
## "n": "type",
## "v": [
## "x",
## "y"
## ],
## "d": "list_of_string"
## },
## {
## "po": 3,
## "n": "type",
## "v": "z",
## "d": "string"
## },
## {
## "po": 4,
## "n": "type",
## "v": [
## "x",
## "y"
## ],
## "d": "list_of_string"
## }
## ]
## },
## {
## "edgeAttributes": [
## {
## "po": 0,
## "n": "type",
## "v": "k",
## "d": "string"
## },
## {
## "po": 1,
## "n": "type",
## "v": "l",
## "d": "string"
## },
## {
## "po": 3,
## "n": "type",
## "v": "n",
## "d": "string"
## },
## {
## "po": 4,
## "n": "type",
## "v": [
## "l",
## "m"
## ],
## "d": "list_of_string"
## }
## ]
## },
## {
## "networkDifferences": [
## {
## "matchByName": "true"
## },
## {
## "nodes": [
## {
## "@id": "0",
## "n": "A",
## "rl": "r1",
## "rr": "r1",
## "oil": "0",
## "oir": "0",
## "btl": "TRUE",
## "btr": "TRUE"
## },
## {
## "@id": "1",
## "n": "B",
## "rl": "r2",
## "rr": "r4",
## "oil": "1",
## "oir": "1",
## "btl": "TRUE",
## "btr": "TRUE"
## },
## {
## "@id": "2",
## "n": "C",
## "rl": "r3",
## "oil": "2",
## "btl": "TRUE",
## "btr": "FALSE"
## },
## {
## "@id": "3",
## "n": "X",
## "rr": "r5",
## "oir": "2",
## "btl": "FALSE",
## "btr": "TRUE"
## }
## ]
## },
## {
## "nodeAttributes": [
## {
## "po": "0",
## "n": "type",
## "btl": "TRUE",
## "btr": "TRUE",
## "dtl": "string",
## "dtr": "string",
## "ill": "FALSE",
## "ilr": "FALSE",
## "vl": "w",
## "vr": "z"
## },
## {
## "po": "1",
## "n": "type",
## "btl": "TRUE",
## "btr": "TRUE",
## "dtl": "string",
## "dtr": "string",
## "ill": "TRUE",
## "ilr": "TRUE",
## "vl": "c(\"x\", \"y\")",
## "vr": "c(\"x\", \"y\")"
## }
## ]
## },
## {
## "edges": [
## {
## "@id": "0",
## "s": "0",
## "t": "1",
## "i": "E1",
## "oil": "0",
## "oir": "0",
## "btl": "TRUE",
## "btr": "TRUE"
## },
## {
## "@id": "1",
## "s": "1",
## "t": "2",
## "i": "E2",
## "oil": "1",
## "btl": "TRUE",
## "btr": "FALSE"
## },
## {
## "@id": "2",
## "s": "2",
## "t": "0",
## "i": "E3",
## "oil": "2",
## "btl": "TRUE",
## "btr": "FALSE"
## },
## {
## "@id": "3",
## "s": "1",
## "t": "3",
## "i": "E2",
## "oir": "1",
## "btl": "FALSE",
## "btr": "TRUE"
## },
## {
## "@id": "4",
## "s": "3",
## "t": "0",
## "i": "E3",
## "oir": "2",
## "btl": "FALSE",
## "btr": "TRUE"
## }
## ]
## },
## {
## "edgeAttributes": [
## {
## "po": "0",
## "n": "type",
## "btl": "TRUE",
## "btr": "TRUE",
## "dtl": "string",
## "dtr": "string",
## "ill": "FALSE",
## "ilr": "FALSE",
## "vl": "k",
## "vr": "n"
## },
## {
## "po": "1",
## "n": "type",
## "btl": "TRUE",
## "btr": "FALSE",
## "dtl": "string",
## "ill": "FALSE",
## "vl": "l"
## },
## {
## "po": "3",
## "n": "type",
## "btl": "FALSE",
## "btr": "TRUE",
## "dtr": "string",
## "ilr": "TRUE",
## "vr": "c(\"l\", \"m\")"
## }
## ]
## },
## {
## "networkAttributes": [
## {
## "n": "name",
## "btl": "TRUE",
## "btr": "TRUE",
## "dtl": "string",
## "dtr": "string",
## "ill": "FALSE",
## "ilr": "FALSE",
## "vl": "left network",
## "vr": "right network"
## },
## {
## "n": "author",
## "btl": "TRUE",
## "btr": "FALSE",
## "dtl": "string",
## "ill": "FALSE",
## "vl": "Donald Duck"
## },
## {
## "n": "description",
## "btl": "FALSE",
## "btr": "TRUE",
## "dtr": "string",
## "ilr": "TRUE",
## "vr": "sample network"
## }
## ]
## }
## ]
## },
## {
## "status": [
## {
## "error": "",
## "success": true
## }
## ]
## }
## ]
##
The re-conversion is the responsibility of the function processCX but before the json-string has to be parsed. The RCX-object is printed and it is identical to the original RCX object.
jsonParsed <- parseJSON(json)
rcx <- processCX(jsonParsed, verbose = TRUE)
## Parsing nodes...create aspect...done!
## Create RCX from parsed nodes...done!
## Parsing edges...create aspect...done!
## Add aspect "edges" to RCX...done!
## Parsing node attributes...create aspect...done!
## Add aspect "nodeAttributes" to RCX...done!
## Parsing edge attributes...create aspect...done!
## Add aspect "edgeAttributes" to RCX...done!
## Parsing networkDifferences...create aspect...done!
## Add aspect "networkDifferences" to RCX...done!
## Parsing meta-data...done!
## Ignore "numberVerification" aspect, not necessary in RCX!
## Can't process aspect "numberVerification", so skip it...done!
## Ignore "status" aspect, not necessary in RCX!
## Can't process aspect "status", so skip it...done!
rcx$metaData
## Meta-data:
## name version idCounter elementCount consistencyGroup
## 1 nodes 1.0 5 6 1
## 2 edges 1.0 5 6 1
## 3 nodeAttributes 1.0 NA 4 1
## 4 edgeAttributes 1.0 NA 4 1
## 5 networkDifferences 1.0 NA 1 1
The NetworkDifferences aspect can be converted to RCX-objects in order to visualize the differences of the RCX-objects left and right. There are three options: node-centered, edge-centered and a combined version. The user can decide if the names and the values of the node- or edgeAttributes should be included. The networkAttributes are not visualized as they are not considered to be important.
The elements that exist in both RCX-objects are colored gray, the elements that exist only in the left RCX-object are colored in light blue and the elements that exist only in the right RCX-object are orange. The shapes for the nodes are:
| RCX Element | Shape |
|---|---|
| node names | round |
| node represents | triangle |
| edge | rectangle |
| nodeAttributes name | hexagon |
| nodeAttribute value | parallelogram |
| edgeAttribute name | rectangle with round corners |
| edgeAttribute value | diamond |
With the node-centered RCX-objects the user can visualize the differences of the two given RCX-objects regarding the nodes and, if wished, the names and values of the nodeAttributes. The exportDifferencesToNodeNetwork-function has the includeNamesAndRepresents-parameter; if this parameter is set to FALSE, either the represents or the names are visualized (depending on matchByName); if includeNamesAndRepresents is set to TRUE, both names and represents are visualized.
A cartesian layout is assigned to the RCX-object that structures the nodes in up to four layers: the innermost layer is for the nodes that belong to both networks, the next layer for the nodes that belongs either to the left or right RCX-object, the third layer (optional) is for the names of the nodeAttributes and the fourth layer (optional) is for the values of the nodeAttributes.
The position of the circles can be changed with several parameters:
startLayerBoth has the default value 5 and determines the position at which the circles for the nodes that belong to both RCX-objects start
startLayerLeftRight has the default value 10 and determines the position at which the circles for the nodes that belong only to one RCX-objects start (it must be greater than startLayerLeftRight). The nodes that belong to the left network are in the left half and the nodes of the right network are located in the right half.
startLayerAttributes has the default value 0 and if this parameter is greater than startLayerLeftRight, it determines the position at which the circles for the names of the nodeAttributes start. The nodeAttributes that belong to both networks are located in the upper half of the circles, the nodeAttributes that belong to the left respectively right network are located in the lower left/right quadrant.
startLayerValues has the default value 0 and if this parameter is greater than startLayerAttributes, it determines the position at which the circles for the values of the nodeAttributes start. The values of the nodeAttributes that belong to both networks are located in the upper half (there can be one gray node if the values are equal in both networks or two nodes (blue and orange) if the values are different), the values of nodeAttributes that belongs only to one network are located in the lower left/right sector.
The following figure shows the the differences of the RCX-objects from the section 1.2 with matchByName set to TRUE.
nodeNetwork <- exportDifferencesToNodeNetwork(
rcxMatchByNameTRUE$networkDifferences, includeNamesAndRepresents = FALSE,
startLayerBoth = 1, startLayerLeftRight = 2, startLayerAttributes = 3,
startLayerValues = 4
)
visualize(nodeNetwork)
Node-centered RCX-object with matchByName TRUE
The next figure shows the result if matchByName is set to FALSE.
nodeNetwork <- exportDifferencesToNodeNetwork(
rcxMatchByNameFALSE$networkDifferences, includeNamesAndRepresents = FALSE,
startLayerBoth = 1, startLayerLeftRight = 2, startLayerAttributes = 3,
startLayerValues = 4
)
visualize(nodeNetwork)
Node-centered RCX-object with matchByName FALSE
The last figure shows the results if matchByName and includeNamesAndRepresentsare TRUE.
nodeNetwork <- exportDifferencesToNodeNetwork(
rcxMatchByNameTRUE$networkDifferences, includeNamesAndRepresents = TRUE,
startLayerBoth = 1, startLayerLeftRight = 2, startLayerAttributes = 3,
startLayerValues = 4
)
visualize(nodeNetwork)
Node-centered RCX-object with matchByName TRUE and includeNamesAndRepresents TRUE
With the edge-centered RCX-objects the user can visualize the differences of the two given RCX-objects regarding the edges and, if wished, the names and values of the edgeAttributes. Like before, there are the parameters startLayerBoth, startLayerLeftRight, startLayerAttributes, and startLayerValues to define the position of the nodes representing the edges and the names and values of the edgeAttributes (for more details see section 2.1).
The following figure shows the edge-centered RCX-object if matchByName is TRUE.
edgeNetwork <- exportDifferencesToEdgeNetwork(
rcxMatchByNameTRUE$networkDifferences, startLayerBoth = 1,
startLayerLeftRight = 2, startLayerAttributes = 3, startLayerValues = 4
)
visualize(edgeNetwork)